<!doctype html>
{% load static %}
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>我的消息</title>
    <link href="{% static 'css/css.css' %}" rel="stylesheet" type="text/css">
    <script src="{% static 'admin/js/jquery.min.js' %}"></script>
</head>
<body>
<div class="zuji_title">
    <span>我的消息</span>
</div>
<br>
<div style="float: left;width: 100%">
    <textarea id="textarea" rows="5" style="width: 90%;font-size: 18px;padding: 20px"></textarea>
    <button onclick="submitFeedback()">提交意见反馈</button>
</div>
<br>
<div class="aaa" style="float: left;width: 100%">
    <ul style="width: 100%;list-style: none;">
    </ul>
</div>
</body>
<script>
    loadFootprint()

    function loadFootprint(){
        $(".aaa > ul").empty();
        $.get(
            "/personal/getFeedback",
            function (res){
                if(res.code==200){
                    let feedbacks = res.data;
                    for(let i=feedbacks.length-1;i>=0;i--){
                        let feedback = feedbacks[i];
                        let li = document.createElement("li");
                        li.style.border = "1px solid #ccc";
                        li.style.width = "100%";
                        li.style.padding = "10px 20px";
                        li.style.boxSizing = "border-box";
                        li.style.margin = "10px 0";
                        let div1 = document.createElement("div");
                        let span1 = document.createElement("span");
                        span1.innerHTML = "<b>意见反馈：</b>" + feedback.back_text;
                        div1.append(span1)
                        li.append(div1);
                        let div2 = document.createElement("div");
                        let span2 = document.createElement("span");
                        if(feedback.reply==null){
                            span2.innerHTML = "<b>作者回复：</b>" + "暂无回复";
                        }else{
                            span2.innerHTML = "<b>作者回复：</b>" + feedback.reply;
                        }
                        div2.append(span2)
                        li.append(div2);
                        $(".aaa > ul").append(li)
                    }
                }
            }
        )
    }

    //进入详情
    function submitFeedback() {
        let backText = $("#textarea").val();
        $.post(
            "/personal/submitFeedback",
            {"backText":backText},
            function (res){
                if(res.code == 200){
                    alert("提交成功")
                    loadFootprint()
                }
            }
        )
    }
</script>
